Skip to main content

48. Loading Pretrained Weights

A pretrained model consists of learned parameter tensors.

pytorchcommonly stores these in a state_dict.

state = model.state_dict()

Loading compatible weights:

model.load_state_dict(state)

The architecture must match the expected parameter shapes and names.

The important principle is:

architecture
↓
matching parameter structure
↓
pretrained weights